package com.css.zfzx.sjcj.modules.hddcRelocationISCatalog.service.impl;

import cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult;
import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler;
import com.css.bpm.platform.utils.PlatformObjectUtils;
import com.css.zfzx.sjcj.common.excel.util.ActiveFaultEasyExcelVerifyHelper;
import com.css.zfzx.sjcj.modules.hddcRelocationISCatalog.viewobjects.HddcRelocationiscatalogVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * <p>地球波数据-小震重新定位目录-点管理 Excel导入校验</p>
 *
 * @author liuhy
 * @date 2021/8/24
 */
@Component
public class RelocationCatalogsPointExcelImportVerifyHandler implements IExcelVerifyHandler<HddcRelocationiscatalogVO> {

    private final ActiveFaultEasyExcelVerifyHelper verifyHelper;

    @Autowired
    public RelocationCatalogsPointExcelImportVerifyHandler(ActiveFaultEasyExcelVerifyHelper verifyHelper) {
        this.verifyHelper = verifyHelper;
    }

    @Override
    public ExcelVerifyHandlerResult verifyHandler(HddcRelocationiscatalogVO vo) {
        ExcelVerifyHandlerResult result = verifyHelper.verify(vo);
        if (PlatformObjectUtils.isEmpty(vo.getMagnitude())) {
            result.setSuccess(false);
            result.setMsg("震级 [Ml]不能为空");
            return result;
        } else if (PlatformObjectUtils.isEmpty(vo.getOccurrencehour())) {
            result.setSuccess(false);
            result.setMsg("时（24小时制）不能为空");
            return result;
        } else if (PlatformObjectUtils.isEmpty(vo.getOccurrenceminute())) {
            result.setSuccess(false);
            result.setMsg("分 不能为空");
            return result;
        } else if (PlatformObjectUtils.isEmpty(vo.getDepth())) {
            result.setSuccess(false);
            result.setMsg("震源深度 [公里] 不能为空");
            return result;
        } else if (PlatformObjectUtils.isEmpty(vo.getOccurrencesecond())) {
            result.setSuccess(false);
            result.setMsg("秒（至少小数点后两位）不能为空");
            return result;
        } else if (PlatformObjectUtils.isEmpty(vo.getRms())) {
            result.setSuccess(false);
            result.setMsg("定位残差 [秒] 不能为空");
            return result;
        }
        result.setSuccess(true);
        return result;
    }

}
